<?php
namespace app\mall\controller\admin;


use suframe\thinkAdmin\traits\CURDController;
use suframe\thinkAdmin\ui\UITable;
use app\mall\model\MallGoodsComment as MallCommentModel;

/**
* 商品评论
*/
class MallComment extends Base
{
    use CURDController;
    protected $urlPre = '/mall/admin/MallComment/';
    /**
     * @param $action
     * @throws \Exception
     */
    private function CURLAllowActions($action)
    {
        $actions = ['index', 'delete'];
        if (!in_array($action, $actions)) {
            throw new \Exception('action not found');
        }
    }
    private function getManageModel()
    {
        return MallCommentModel::class;
    }

    private function ajaxSearch()
    {
        $rs = $this->parseSearchWhere($this->getManageModel(), [
            'create_time' => 'betweenTime',
            'comment' => 'like',
        ]);
        $rs->append(['goods_title', 'store_name', 'user_nickname']);
        return json_return($rs);
    }

    /**
     * @param \suframe\form\Form $form
     * @throws \FormBuilder\Exception\FormBuilderException
     * @throws \ReflectionException
     */
    private function getFormSetting($form)
    {
        $form->setRuleByClass(\app\mall\ui\form\MallGoodsCommentForm::class);
    }

    /**
     * @param UITable $table
     */
    private function getTableSetting($table)
    {
        $table->createByClass(\app\mall\ui\table\MallGoodsCommentTable::class);
        $table->setDeleteOps($this->urlA('delete'), ['id']);
    }
}